<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>反馈详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">反馈id</label>
        <div class="layui-input-block">
            <input type="text" name="id"  id="id" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">openid</label>
        <div class="layui-input-block">
            <input type="text" name="openid"  id="openid" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">用户名</label>
        <div class="layui-input-block">
            <input type="text" id="username" name="username"  value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系电话</label>
        <div class="layui-input-block">
            <input type="text" name="userphone" id="userphone" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">反馈内容</label>
        <div class="layui-input-block">
            <input type="text" name="content" id="content" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">反馈时间</label>
        <div class="layui-input-block">
            <input type="text" name="contenttime" id="contenttime" readonly  value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required" >回复内容</label>
        <div class="layui-input-block">
            <input type="text" name="reply" id="reply" value="" class="layui-input" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">彩金赠送</label>
        <div class="layui-input-block">
            <input type="radio" name="caijin" value="是" title="是" lay-filter="choiceradio">
            <input type="radio" name="caijin" value="否" title="否" checked lay-filter="choiceradio">
        </div>
    </div>

    <div class="layui-form-item" id="divmoney" style="display: none;">
        <label class="layui-form-label">彩金金额</label>
        <div class="layui-input-block">
            <input type="text" name="handsel" id="handsel"  value="" class="layui-input" lay-min="4">
        </div>
    </div>
<!--
    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-block">
           <img src="" id="orderImg" height="300" width="600">
        </div>
    </div>-->

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" id="butt" lay-submit lay-filter="saveBtn">确认回复</button>
        </div>
    </div>
</div>
</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../../lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>

<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var handsel=document.getElementById("handsel").value;
            document.getElementById("handsel").value=handsel;
            //系统公告
            $.ajax({
                type: "post",
                url: "../feedback/updatefeedback",
                dataType: "json",
                contentType:'application/json;charset=utf-8',
                data:JSON.stringify(data.field),
                success: function (result) {
                    if(result.result=="success"){
                        layer.alert('回复成功啦~~~！', {icon: 1});
                        setTimeout(function () {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            //parent.$("#shousuobtn",parent.document).trigger('click');	//子页面局部刷新父页面事件
                            window.parent.document.getElementById("shousuobtn").click();
                        }, 2000);



                    }
                },
                error: function () {
                    console.log("网络出错！请重新连接")
                }
            });

            return false;
        });
        form.on('radio(choiceradio)', function(data){

            if(data.value=="是"){
                document.getElementById("divmoney").style.display="";//显示
                document.getElementById("handsel").setAttribute('lay-verify','required|account|number');
                // lay-verify="required|account|number"
            }else{
                document.getElementById("divmoney").style.display="none";//隐藏
                document.getElementById("handsel").removeAttribute("lay-verify 'required|account|number'");
                document.getElementById('handsel').value="";
            }
        });

        //检查输入的账号长度
        form.verify({
            account: function(value, item){
                var min = item.getAttribute('lay-min');
                if(value.length > min){
                    return '金额不能大于'+min+'个的长度';
                }
            }
        });

    });

    $(document).ready(function(){
        //id查询赋值
        $.ajax({
            type: "get",
            url: "../feedback/idquerysession",
            dataType: "json",
            success: function (result) {
                $("#id").attr("value",result.feedback.id);
                $("#username").attr("value",result.feedback.username);
                $("#userphone").attr("value",result.feedback.userphone);
                $("#content").attr("value",result.feedback.content);
                $("#reply").attr("value",result.feedback.reply);
                $("#contenttime").attr("value",result.feedback.contenttime);
                $("#repletime").attr("value",result.feedback.repletime);
                $("#good").attr("value",result.feedback.good);
                $("#openid").attr("value",result.feedback.openid);
            },
            error: function () {
                console.log("网络出错！请重新连接")
            }
        });
        setTimeout(function () {
            var reply=document.getElementById("reply").value;
            console.log(reply);
            if(reply!=""||undefined ||null){
                $('#butt').addClass("layui-btn-disabled").attr("disabled",true);
                $("input:radio[name='caijin']:not(:checked)").attr("disabled", true).prop("disabled", true);
            }
        }, 200);

    });
</script>
</body>
</html>